/**
 * show ace editor
 * @param rId
 * @param cId
 * @param mode
 */
function fmdexf_showAceEditor(rId, cId, title, mode, isEditor) {
	//alert(rId+"="+cId+"="+mode);
	var lo1 = fm_createCenterWindowLayout("win_prop_style", title, 800, 600, "1C", dhx_skin, "script_tag");
	var obj = document.createElement("div");
	obj.id="prop_ace_editor";
	lo1.cells("a").hideHeader();
	lo1.cells("a").attachObject(obj);
	//editor
	var prop_ace_editor = ace.edit("prop_ace_editor");
	prop_ace_editor.setTheme("ace/theme/tomorrow");
	prop_ace_editor.getSession().setMode("ace/mode/"+mode);
	prop_ace_editor.setValue(fmdc.grid_prop.cells(rId, cId).getValue());
	if (!isEditor) {
		prop_ace_editor.setReadOnly(true);
	} else {
		//toolbar
		var tb = lo1.cells("a").attachToolbar();
		tb.setIconsPath(fmdc.imagepath);
		tb.addButton('ok', 0, fmd_i18n_b_ok, 'ok.png', null);
		tb.attachEvent("onClick", function(id){
			if ("ok"==id) {
				fmdc.grid_prop.cells(rId, cId).setValue(prop_ace_editor.getValue());
				fm_closeWindow("win_prop_style");
			}
		});
	}
}

/**
 * show ace javascript editor
 * @param rId
 * @param cId
 * @param mode
 */
function fmdexf_showAceEditorJs(rId, cId, title, mode, isEditor) {
	//alert(" rId="+rId+" cId="+cId+" mode="+mode);
	var lo1 = fm_createCenterWindowLayout("win_prop_style", title, 800, 600, "2E", dhx_skin, "script_tag");
	var obj = document.createElement("div");
	obj.id="prop_ace_editor";
	lo1.cells("a").hideHeader();
	lo1.cells("b").hideHeader();
	lo1.cells("b").attachObject(obj);
	//signature
	var args = fmdc.grid_prop.cells(rId, cId).getArgs();
	if (args) {
		var str1 = "<p style='font-size:0.75em'>"+ fmd_i18n_funcsignature + " function(";
		var arg1 = "";
		var j=0;
		for (var i in args) {
			if (j) {
				str1 += ","; 
				arg1+="<br/>";
			};
			str1 += i;
			arg1 += i + " : " + args[i];
			j++;
		}
		str1 += "){...}<br/>"+arg1+"</p>";
		lo1.cells("a").setHeight(120);
		lo1.cells("a").attachHTMLString(str1);
	} else {
		lo1.cells("a").setHeight(120);
		lo1.cells("a").attachHTMLString("<p style='font-size:0.75em'>"+ fmd_i18n_funcsignature + " function(){...}</p>");
	}
	
	//editor
	var prop_ace_editor = ace.edit("prop_ace_editor");
	prop_ace_editor.setTheme("ace/theme/tomorrow");
	prop_ace_editor.getSession().setMode("ace/mode/"+mode);
	prop_ace_editor.setValue(fmdc.grid_prop.cells(rId, cId).getValue());
	if (!isEditor) {
		prop_ace_editor.setReadOnly(true);
	} else {
		//toolbar
		var tb = lo1.cells("a").attachToolbar();
		tb.setIconsPath(fmdc.imagepath);
		tb.addButton('ok', 0, fmd_i18n_b_ok, 'ok.png', null);
		tb.attachEvent("onClick", function(id){
			if ("ok"==id) {
				fmdc.grid_prop.cells(rId, cId).setValue(prop_ace_editor.getValue());
				fm_closeWindow("win_prop_style");
			}
		});
	}
}

//show validation window
function fmdexf_showAceValidationJs(rId, cId, title, mode, isEditor) {
	var valichanged = false;
	//check require
	var params = fmdc.grid_prop.cells(rId, cId).getParams();
	if (params.require) {
		if (!fmdc.grid_prop.cells(params.require, fmdmeta_prop.gridconf.idx.value).getValue()) {
			msg(fmd_i18n_msg_plsinput + ":" +fmdc.grid_prop.cells(params.require, fmdmeta_prop.gridconf.idx.prop).getValue());
			return;
		}
	}
	//alert(" rId="+rId+" cId="+cId+" mode="+mode);
	var lo = fm_createCenterWindowLayout("win_prop_validation", title, 800, 600, "1C", dhx_skin, "script_tag");
	fm_dhxWins.window('win_prop_validation').attachEvent('onClose', function() {
		if (valichanged) {
			dhtmlx.message({
				type:"confirm",
	            ok:fmd_i18n_b_ok,
	            cancel:fmd_i18n_b_cancel,
				text: fmd_i18n_msg_unsavedchange,
				callback: function(yes) {
					if(yes) {
						valichanged = false;
						fm_closeWindow('win_prop_validation');
					}
				}
			});
		} else {
			return true;
		}
	});
	
	var tab1 = lo.cells('a').attachTabbar();
	tab1.addTab('gui', fmd_i18n_ext_validation_gui);
	tab1.cells('gui').setActive();
	
	//get value
	var valistr = fmdc.grid_prop.cells(rId, cId).getValue();
	//alert(JSON.stringify(valistr));
	var valiv = valistr ? JSON.parse(valistr) : {};
	
	//init gui tab
	/*var lo1 = tab1.cells('gui').attachLayout('2E');
	lo1.cells("a").setText(fmd_i18n_ext_validation_auto);
	lo1.cells("b").setText(fmd_i18n_ext_validation_manual);*/
	var vgidx = 1;
	var cvgidx = 1;
	
	var vg = tab1.cells('gui').attachGrid();
	vg.setIconsPath(fmdc.imagepath);
	vg.setHeader([fmd_i18n_validator,
	              fmd_i18n_ext_validation_condition,
	              fmd_i18n_l_script,
	              fmd_i18n_ext_validation_desc,
	              "#cspan"],
                    null,
                    ["text-align:center;",
                     "text-align:center;",
                     "text-align:center;",
                     "text-align:center;",
                     "text-align:center;"]);
	vg.attachHeader("#rspan,#rspan,#rspan,"+fmd_i18n_prop_i18nname_zh+","+fmd_i18n_prop_i18nname_en);
	vg.setInitWidths("120,120,70,270,270");
	vg.setColumnIds("VALIDATION,CONDITION,SCRIPT,DESC_ZH,DESC_EN");
	vg.setColTypes("coro,rotxt,rotxt,ed,ed");
	vg.setColSorting("na,na,na,na,na");
	vg.setColAlign("left,left,left,left,left");
	vg.setColumnsVisibility("false,false,false,false,false");
	vg.setEditable(isEditor);
	if (typeof(fmd)!='undefined') vg.setLang(fmd.lang);
	vg.enableDragAndDrop(true);
	vg.enableValidation(true,true);
        vg.setColValidators([null,null,null,"NotEmpty","NotEmpty"]);
	vg.init();
	vg.grid_bindColCombo(0, fmdmeta_prop.runtime_validators, {"comboSize":10, "comboWidth":260});
	
	//set data
	if (valiv.gui) {
		vg.parse(valiv.gui, 'json');
		vgidx = vg.getRowsNum() +1;
		var rn = vg.getRowsNum();
		if (rn) {//set validation for condition column
			for (var i=0; i<rn; i++) {
				if (fmdmeta_prop.validators[vg.cellByIndex(i, 0).getValue()]["condition"]) {
					vg.setCellExcellType(vg.getRowId(i), 1, 'ed');
					var val1 = "NotEmpty";
					if (fmdmeta_prop.validators[vg.cellByIndex(i, 0).getValue()]["conditionValidator"]) {
						val1+= ","+fmdmeta_prop.validators[vg.cellByIndex(i, 0).getValue()]["conditionValidator"];
					}
					vg.cellByIndex(i, 1).setAttribute("validate",val1);
				}
			}
		}
	}
	
	vg.attachEvent('onCellChanged', function(rId,cInd,nv){
		if (0==cInd && nv!='None') {
			!vg.cells(rId, 3).getValue() && vg.cells(rId, 3).setValue(fmdmeta_prop.validators[nv].zh);
			!vg.cells(rId, 4).getValue() && vg.cells(rId, 4).setValue(fmdmeta_prop.validators[nv].en);
			vg.cells(rId, 2).setValue(fmdmeta_prop.validators[nv]["func"]);
			if (fmdmeta_prop.validators[nv]["condition"]) {
				vg.setCellExcellType(rId, 1, 'ed');
				var val1 = "NotEmpty";
				if (fmdmeta_prop.validators[vg.cells(rId, 0).getValue()]["conditionValidator"]) {
					val1+= ","+fmdmeta_prop.validators[vg.cells(rId, 0).getValue()]["conditionValidator"];
				}
				vg.cells(rId, 1).setAttribute("validate",val1);
			} else {
				vg.cells(rId, 1).setAttribute("validate", '');
				vg.setCellExcellType(rId, 1, 'rotxt');
				vg.cells(rId, 1).setValue('');
				$(vg.cells(rId,1).cell).removeClass("dhtmlx_validation_error");
			}
		}
	});
	
	//gui toolbar
	if (isEditor) {
		var tbg = tab1.cells('gui').attachToolbar();
		tbg.setIconsPath(fmdc.imagepath);
		tbg.addButton('tbg_del',0,'',"delete1.gif","delete1_dis.gif");
		tbg.addButton('tbg_new',0,'',"new1.gif","new1_dis.gif");
		tbg.disableItem('tbg_del');
		tbg.attachEvent('onClick', function(tbid){
			if ('tbg_new'==tbid) {
				vg.addRow(vgidx, ["None", "", "", "", ""]);
				vgidx++;
			} else if ('tbg_del'==tbid) {
				if(vg.getSelectedRowId()!=undefined){
					vg.deleteRow(vg.getSelectedRowId());
					tbg.disableItem('tbg_del');
				}
			}
		});
		vg.attachEvent('onSelectStateChanged', function(id){
			if (id!==undefined) tbg.enableItem('tbg_del');
		});
	}
	
	//init custom tab
	var cvg = null;
	var prop_cs_editor = null;
	if (fmdc.advancedview) {
		tab1.addTab('custom', fmd_i18n_ext_validation_custom);
		var obj = document.createElement("div");
		obj.id="custom_validation_div";
		tab1.cells('custom').attachObject(obj);
		
		//signature
		var str1 = "function(";
		var arg1 = "";
		var args = fmdc.grid_prop.cells(rId, cId).getArgs();
		if (args) {
			var j=0;
			for (var i in args) {
				if (j) {
					str1 += ","; 
					arg1+=",&nbsp;";
				};
				str1 += i;
				arg1 += i + " : " + args[i];
				j++;
			}
		}
		arg1 += ",&nbsp;" + fmd_i18n_vfuncreturn;
		str1 += ")";
		var str2 = "<p style='font-size:0.75em'>"+ arg1 + "<br/>" +fmd_i18n_funcsignature + ":<br/>" + str1 + "&nbsp;{</p>";
		$('#custom_validation_div').append('<div id="prop_ace_cvg" style="height:200px;width:100%"></div>'+
				'<div id="prop_ace_cveditor_w" style="height:250px;;width:100%">' +
				'<div id="prop_ace_cveditor_desc1" style="height:50px;;width:100%">'+
				'</div><div id="prop_ace_cveditor" style="height:180px;width:100%">'+
				'</div><div style="height:20px;width:100%;font-size:0.75em">}</div></div>');
		$('#prop_ace_cveditor_desc1').append(str2);
		
		//editor
		prop_cs_editor = ace.edit("prop_ace_cveditor");
		prop_cs_editor.setTheme("ace/theme/tomorrow");
		prop_cs_editor.getSession().setMode("ace/mode/"+mode);
		prop_cs_editor.resize();
		valiv.custom && prop_cs_editor.setValue(valiv.custom.func);
		prop_cs_editor.on("change", function(e){valichanged = true;});
		prop_cs_editor.setReadOnly(true);
		$('#prop_ace_cveditor_w').hide();
		
		//grid
		cvg = new dhtmlXGridObject('prop_ace_cvg');
		cvg.setIconsPath(fmdc.imagepath);
		cvg.setHeader([fmd_i18n_l_script,
		              fmd_i18n_ext_validation_desc,
		              "#cspan"],
	                    null,
	                    ["text-align:center;",
	                     "text-align:center;",
	                     "text-align:center;"]);
		cvg.attachHeader("#rspan,"+fmd_i18n_prop_i18nname_zh+","+fmd_i18n_prop_i18nname_en);
		cvg.setInitWidths("200,270,270");
		cvg.setColumnIds("SCRIPT,DESC_ZH,DESC_EN");
		cvg.setColTypes("rotxt,ed,ed");
		cvg.setColSorting("na,na,na");
		cvg.setColAlign("left,left,left");
		cvg.setColumnsVisibility("false,false,false");
		cvg.setEditable(isEditor);
		if (typeof(fmd)!='undefined') cvg.setLang(fmd.lang);
		cvg.enableDragAndDrop(true);
		cvg.enableValidation(true,true);
	    cvg.setColValidators(["NotEmpty","NotEmpty","NotEmpty"]);
		cvg.init();
		
		//toolbar
		var ctb = null;
		if (isEditor) {
			ctb = tab1.cells('custom').attachToolbar();
			ctb.setIconsPath(fmdc.imagepath);
			ctb.addButton('ctb_apply', 0, fmd_i18n_vld_applyscript, "apply.gif","apply_dis.gif");
			ctb.addButton('ctb_del',0,'',"delete1.gif","delete1_dis.gif");
			ctb.addButton('ctb_new',0,'',"new1.gif","new1_dis.gif");
			ctb.disableItem('ctb_del');
			ctb.attachEvent("onClick", function(id){
				if ("ctb_apply"==id) {
					if(cvg.getSelectedRowId()!=undefined){
						cvg.cells(cvg.getSelectedRowId(), 0).setValue(prop_cs_editor.getValue());
					}
					valichanged = false;
				} else if ("ctb_del"==id) {
					if(cvg.getSelectedRowId()!=undefined){
						cvg.deleteRow(cvg.getSelectedRowId());
						ctb.disableItem('ctb_del');
						$('#prop_ace_cveditor_w').hide();
					}
				} else if ("ctb_new"==id) {
					cvg.addRow(cvgidx, ["return true;", "", ""]);
					cvgidx++;
				}
			});
			
		}
		
		cvg.attachEvent("onBeforeSelect", function(new_row,old_row){
			if (new_row!=old_row && valichanged) {
				msg(fmd_i18n_msg_plsapplyscript);
				return false;
			}
			return true;
		});
		
		cvg.attachEvent('onSelectStateChanged', function(id){
			if (id!==undefined) {
				if (isEditor) {
					ctb.enableItem('ctb_del');
				}
				prop_cs_editor.setReadOnly(!isEditor);
				prop_cs_editor.setValue(cvg.cells(id, 0).getValue());
				$('#prop_ace_cveditor_w').show();
			} else {
				prop_cs_editor.setValue('');
				prop_cs_editor.setReadOnly(true);
				$('#prop_ace_cveditor_w').hide();
			}
			valichanged = false;
		});
		
		if (valiv.custom) {
			cvg.parse(valiv.custom, 'json');
			cvgidx = cvg.getRowsNum() +1;
		}
		
	}
	
	//readonly?
	if (isEditor) {
		//toolbar
		var tb = lo.cells("a").attachToolbar();
		tb.setIconsPath(fmdc.imagepath);
		tb.addButton('ok', 0, fmd_i18n_b_ok, 'ok.png', null);
		tb.attachEvent("onClick", function(id){
			if ("ok"==id) {
				//gui
				var rn = vg.getRowsNum();
				var gdata = {rows:[]};
				if (rn) {
					var idx = 1;
					for (var i=0; i<rn; i++) {
						var data = [];
						data[0] = vg.cellByIndex(i, 0).getValue();
						data[1] = vg.cellByIndex(i, 1).getValue();
						data[2] = vg.cellByIndex(i, 2).getValue();
						data[3] = vg.cellByIndex(i, 3).getValue();
						data[4] = vg.cellByIndex(i, 4).getValue();
						if (data[0]=='None') {
							msg(fmd_i18n_msg_plscompleteinfo);
							return;
						}
						//alert(i+"="+vg.validateCell(vg.getRowId(i), 1));
						if (vg.cellByIndex(i, 1).getAttribute('validate') && vg.validateCell(vg.getRowId(i), 1)===false) {
							msg(fmd_i18n_msg_plscompleteinfo);
							return;
						}
						if (!data[2]) {
							msg(fmd_i18n_msg_plscompleteinfo);
							return;
						}
						if (!data[3]) {
							msg(fmd_i18n_msg_plscompleteinfo);
							return;
						}
						gdata.rows.push({"id":idx++, "data": data});
					}
				}
				valiv.gui = gdata;
				//custom
				if (fmdc.advancedview) {
					if(cvg.getSelectedRowId()!=undefined && valichanged){
						cvg.cells(cvg.getSelectedRowId(), 0).setValue(prop_cs_editor.getValue());
						valichanged = false;
					}
					var rn1 = cvg.getRowsNum();
					if (rn1) {
						var cgdata = {rows:[]};
						var cidx = 1;
						for (var j=0; j<rn1; j++) {
							var data1 = [];
							data1[0] = cvg.cellByIndex(j, 0).getValue();
							data1[1] = cvg.cellByIndex(j, 1).getValue();
							data1[2] = cvg.cellByIndex(j, 2).getValue();
							if (!data1[0]) {
								msg(fmd_i18n_msg_plscompleteinfo);
								return;
							}
							if (!data1[1]) {
								msg(fmd_i18n_msg_plscompleteinfo);
								return;
							}
							if (!data1[2]) {
								msg(fmd_i18n_msg_plscompleteinfo);
								return;
							}
							cgdata.rows.push({"id":cidx++, "data": data1});
						}
						valiv.custom = cgdata;
					}
				}
				
				//add type
				valiv.type = 'validation';
				//add input index
				valiv.inputindex = params.inputindex;
				
				//console.log(JSON.stringify(valiv));
				fmdc.grid_prop.cells(rId, cId).setValue(JSON.stringify(valiv));
				fm_closeWindow("win_prop_validation");
			}
		});
	}
}

//btnex excel type button click event
function fmdexf_btnexClick(e, obj, rId, cId, tag) {
	if (tag) {
		$(obj).parents('td')[0].btnex_onclick1();
	} else {
		$(obj).parents('td')[0].btnex_onclick();
	}
}

//create pairro excel type, data type like "KEY_@!@_VALUE"
function eXcell_pairro(cell){//excell name is defined here
    if (cell){
        this.cell = cell;
        this.grid = this.cell.parentNode.grid;
    }
    this.edit = function(){}; //read-only cell doesn't have edit method
    this.isDisabled = function(){ return true; }; // the cell is read-only, that's why it is always in the disabled state
    this.setValue=function(val) {
    	if (undefined!=val) {
    		var keyvalue = (val.toString()).split(pairro_spliter, 2);
    		//alert(this.cell.parentNode.idd+'  '+this.cell._cellIndex+'     '+keyvalue.length+'    '+keyvalue[0]+'='+keyvalue[1]);
    		this.setCValue("<span style='display:none'>"+keyvalue[0]+"</span>"+(keyvalue.length==1?keyvalue[0]:(keyvalue[1]=='undefined'?'':keyvalue[1])),val);
    	} else {
    		this.setCValue("<span style='display:none'></span>",val);
    	}
    	//this.setCValue("<span style='display:none'>"+val+"</span>"+val);
    };
    this.getValue=function(){
    	return this.cell.childNodes[0].innerHTML; // get value
    	//return this.cell.innerHTML;
    };
}
eXcell_pairro.prototype = new eXcell;

//create bilingual excel type, data type like "VALUE_zh@VALUE_en"
function eXcell_bilingualro(cell){//excell name is defined here
    if (cell){
        this.cell = cell;
        this.grid = this.cell.parentNode.grid;
    }
    this.edit = function(){}; //read-only cell doesn't have edit method
    this.isDisabled = function(){ return true; }; // the cell is read-only, that's why it is always in the disabled state
    this.setValue=function(val) {
    	if (undefined!=val) {
    		var keyvalue = (val.toString()).split(bilingualro_spliter, 2);
    		var dval = null;
    		if (keyvalue.length==1) {
    			dval = keyvalue[0];
    		} else {
    			if ('zh'==this.grid.getLang()) {
    				dval = keyvalue[0];
    			} else {
    				dval = keyvalue[1];
    			}
    		}
    		this.setCValue("<span style='display:none'>"+val+"</span>"+dval,val);
    	} else {
    		this.setCValue("<span style='display:none'></span>",val);
    	}
    	//this.setCValue("<span style='display:none'>"+val+"</span>"+val);
    };
    this.getValue=function(){
    	return this.getValueByLang();
    };
    this.getValueByLang=function(_lang){
    	if (undefined==_lang) {
    		return this.cell.childNodes[0].innerHTML; // get value
    	} else if ('zh'==_lang) {
    		var val = this.cell.childNodes[0].innerHTML;
    		return val.split(bilingualro_spliter, 2)[0];
    	} else {
    		var val = this.cell.childNodes[0].innerHTML;
    		var keyvalue = val.split(bilingualro_spliter, 2);
    		if (keyvalue.length==1) {
    			return keyvalue[0];
    		} else {
    			return keyvalue[1];
    		}
    	}
    };
}
eXcell_bilingualro.prototype = new eXcell;

//new eXcell type - colist, is a checkbox list represents key-value pairs data
function eXcell_colist(cell){
	try{
		this.cell = cell;
		this.grid = this.cell.parentNode.grid;
	}catch(er){
	}
	//edit
	this.edit = function(){
		///alert("this.getValue()="+this.getValue());
		//alert("this.getValue(0)="+this.getValue(0));
		this.val = this.getValue();
		var a = this.getValue(0);
		if (!a) {
			return false;
		}
		this.obj = document.createElement("DIV");
        var b=this.val.split(",");
        var text="";

        for (var i=0; i<a.length; i++){
            var fl1=false;
            for (var j=0; j<b.length; j++) {
            	if (a[i][0]==b[j]) fl1=true;
            }
            if (fl1) {
            	text+="<div style='white-space:nowrap'><input type='checkbox' checked='true' value='"+a[i][0]+"'/><label for='dhx_colist_"+i+"'>"+a[i][1]+"</label></div>";
            } else {
            	text+="<div style='white-space:nowrap'><input type='checkbox' value='"+a[i][0]+"'/><label for='dhx_colist_"+i+"'>"+a[i][1]+"</label></div>";
            }
        }
        text+="<div><input type='hidden'></input><img src='"+this.grid.extIconPath+"ok.png' class='btn_pic' onclick='this.parentNode.childNodes[0].value=\"clicked\";this.parentNode.parentNode.editor.grid.editStop();'/>&nbsp;<img src='"+this.grid.extIconPath+"cancel.png'  class='btn_pic' onclick='this.parentNode.parentNode.editor.grid.editStop();'/></div>";

        this.obj.editor=this;
        this.obj.innerHTML=text;
        document.body.appendChild(this.obj);
        this.obj.style.position="absolute";
        this.obj.style.width="150px";
        this.obj.style.height="100px";
        this.obj.style.overflow="auto";
		this.obj.className="dhx_colist";
		this.obj.onclick=function(e){(e||event).cancelBubble=true; return true;};
		var arPos = this.grid.getPosition(this.cell);
        this.obj.style.left=arPos[0]+"px";
        this.obj.style.top=arPos[1]+this.cell.offsetHeight+"px";

        this.obj.getValue=function(){
            var text="";
            for (var i=0; i<this.childNodes.length-1; i++) {
                if (this.childNodes[i].childNodes[0].checked){
                    if (text) text+=",";
                    text+=this.childNodes[i].childNodes[0].value;
                }
            }
            return text.replace(/&amp;/g,"&");
        };
        this.obj.getDisplayValue=function(){
            var text="";
            for (var i=0; i<this.childNodes.length-1; i++) {
                if (this.childNodes[i].childNodes[0].checked){
                    if (text) text+=",";
                    text+=this.childNodes[i].childNodes[1].innerHTML;
                }
        	}
            return text.replace(/&amp;/g,"&");
        };
        this.obj.isOk=function(){
            return this.childNodes[this.childNodes.length-1].childNodes[0].value=='clicked';
        };
	};
	//get value
	this.getValue = function(i){
		//this.grid.editStop();
		if (this.cell._clearCell) return "";
		//return this.cell.innerHTML.toString()._dhx_trim().replace(/&amp;/g,"&");
		if (this.cell.innerHTML=='' || !this.cell.childNodes[i!=undefined?i:1]) {
			return null;
		}
		if (i==0) {
			return this.cell.childNodes[0].value ? JSON.parse(this.cell.childNodes[0].value) : null;
		} else if (i==2) {
			return this.cell.childNodes[2].innerHTML;
		} else {
			return this.cell.childNodes[1].value; // get value
		}
	};
	//detach
	this.detach = function(val){
		//alert('detach, this.obj.isOk()='+this.obj.isOk());
        if (this.obj){
        	if (this.obj.isOk()) {
        		//alert('detach and setvalue this.obj.getValue()='+this.obj.getValue()+' this.obj.getDisplayValue()='+this.obj.getDisplayValue());
    			this.setValue(this.obj.getValue(), this.obj.getDisplayValue());
        	}
            this.obj.editor=null;
            this.obj.parentNode.removeChild(this.obj);
            this.obj=null;
        }
		return this.val!=this.getValue();
	};
	//set value
	this.setValue = function(val){
		//alert('setValue val='+val+"  dispval="+dispval);
		if (val==undefined || val==="" || val === this.undefined || this.getValue(0)==null){
			this.val = '';
			if (this.cell.childNodes[1]) {
				this.cell.childNodes[1].value = '';
				this.cell.childNodes[2].innerHTML = '';
			}
			//this.cell._clearCell=true;
			this.setCValue(this.cell.innerHTML, this.val);//must call to enable cellchanged event
			//this.cell._clearCell=false;
		} else{
			var list = this.getValue(0);
			if (typeof(val)=="string"){
				this.val = val;
                this.dispval = '';
				var vals = val.split(',');
                for (var i in list) {
                    for (var j in vals) {
                        if(list[i][0]==vals[j]) {
                            this.dispval += this.dispval ? (","+list[i][1]) : list[i][1];
                        }
                    }
                }
			} else if (typeof(val)=="object" && val.length) {
				this.val = JSON.stringify(val);
				this.dispval = '';
				for (var i in list) {
					for (var j in val) {
						if(list[i][0]==val[j]) {
							this.dispval += this.dispval ? (","+list[i][1]) : list[i][1];
						}
					}
				}
			}
	        //this.setCValue('<span style="display:none">'+this.val+'</span><span>1</span><span>2</span>', val);
			this.setCValue(this.cell.innerHTML, this.val);//must call to enable cellchanged event
			this.cell.childNodes[1].value = this.val;
			this.cell.childNodes[2].innerHTML = this.dispval;
			this.cell._clearCell=false;
	    }
	};
	//init list data before using
	this.setConfig = function(conf){
		var list = conf.list;
		var val = conf.val;
		var dispval = conf.displayVal;
		//alert('setList typeof(list)='+typeof(list)+"  val="+list);
		if (list==="" || list === this.undefined){
			this.setCTxtValue("",list);
			this.cell._clearCell=true;
		} else{
			//set list
			if (typeof(list)=="string"){
				this.list = list;
			} else if (typeof(list)=="object") {
				this.list = JSON.stringify(list);
			}
	    	//this.setCTxtValue(val);
			//set value
			this.val = val || '';
			this.dispval = dispval || '';
	        this.setCValue('<input type="hidden"/><input type="hidden"/><span>'+this.dispval+'</span>', val);
	        this.cell.childNodes[0].value = this.list;
	        this.cell.childNodes[1].value = this.val;
	    	this.cell._clearCell=false;
	    }
	};
}
eXcell_colist.prototype = new eXcell;//new eXcell type

//i18n excell type
function eXcell_i18n(cell) { //excell name is defined here
	if (cell) { //default pattern, just copy it
		this.cell = cell;
		this.grid = this.cell.parentNode.grid;
	};
	this.setValue = function(val) {
		this.setCValue(val);
	};
	this.getValue = function() {
		return this.cell.innerHTML; // get value
	};
	this.edit = function() {
		this.val = this.getValue(); //save current value
		this.cell.innerHTML = "<input type='text' style='width:50px;'><select style='width:50px;'><option value='AM'>AM<option value='PM'>PM</select>"; // editor's html
		this.cell.firstChild.value = parseInt(this.val); //set the first part of data

		this.cell.childNodes[0].onclick = function(e) {
			(e || event).cancelBubble = true;
		}; //block onclick event
		this.cell.childNodes[1].onclick = function(e) {
			(e || event).cancelBubble = true;
		}; //block onclick event
	};
	this.detach = function() {
		this.setValue(this.cell.childNodes[0].value + " "
				+ this.cell.childNodes[1].value); //set the new value
		return this.val != this.getValue(); // compare the new and the old values
	};
}
eXcell_i18n.prototype = new eXcell; // nest all other methods from base class


//ace_css excell type
function eXcell_ace_text(cell) { //excell name is defined here
	if (cell) { //default pattern, just copy it
		this.cell = cell;
		this.grid = this.cell.parentNode.grid;
		//this.cell.innerHTML = "<input type='hidden'/><img src='"+this.grid.extIconPath+"display.png"+"'/>";
	};
	this.edit = function(){}; //read-only cell doesn't have edit method
    this.isDisabled = function(){ return true; };
	this.setValue = function(val) {
		var rId=this.cell.parentNode.idd;	//rowId
    	var cId=this.cell._cellIndex;	//column index
		var imgName = val ? "update.gif" : "new.gif";
		var alt_edit = "<font color='gray'>"+this.grid.i18n.extypes_edit+"</font>";
		var alt_sel = "<font color='gray'>"+this.grid.i18n.extypes_sel+"</font>";
		var alt_view = "<font color='gray'>"+this.grid.i18n.extypes_view+"</font>";
		var alt = this.grid.isEditor ? (val ? alt_edit : alt_sel) : alt_view;
		this.setCValue("<input type='hidden'/><img src='"+this.grid.extIconPath+imgName+
				"' style='cursor:pointer;' align='absmiddle' onclick='fmdexf_showAceEditor(\""+
				rId+"\", "+cId+", \""+fmd_i18n_style+"\", \"text\", "+this.grid.isEditor+")' " +
				"onmouseover='changeicosize(this,true)' onmouseout='changeicosize(this,false)'/>"+alt,
				val);
		this.cell.firstChild.value = val;
	};
	this.getValue = function() {
		return this.cell.firstChild.value; // get value
	};
}
eXcell_ace_text.prototype = new eXcell; // nest all other methods from base class

//ace_script excell type
function eXcell_ace_javascript(cell) { //excell name is defined here
	if (cell) {
		this.cell = cell;
		this.grid = this.cell.parentNode.grid;
	};
	this.edit = function(){}; //read-only cell doesn't have edit method
    this.isDisabled = function(){ return true; };
    this.setArgs = function(conf) {
    	//console.debug("setConfig="+JSON.stringify(conf));
    	this.cell.childNodes[1].value = conf ? JSON.stringify(conf) : "";
	};
	this.setValue = function(val) {
		//console.debug("eXcell_ace_javascript setValue value="+val);
		var rId=this.cell.parentNode.idd;	//rowId
    	var cId=this.cell._cellIndex;	//column index
    	this.cell.firstChild.value = val;
		var imgName = val ? "update.gif" : "new.gif";
		var alt_edit = "<font color='gray'>"+this.grid.i18n.extypes_edit+"</font>";
		var alt_sel = "<font color='gray'>"+this.grid.i18n.extypes_sel+"</font>";
		var alt_view = "<font color='gray'>"+this.grid.i18n.extypes_view+"</font>";
		var alt = this.grid.isEditor ? (val ? alt_edit : alt_sel) : alt_view;
		var args = (this.cell.childNodes && this.cell.childNodes.length>1 && this.cell.childNodes[1] && this.cell.childNodes[1].value)
				? this.cell.childNodes[1].value : "";
		this.setCValue("<input type='hidden'/><input type='hidden'/><img src='"+this.grid.extIconPath+imgName+
				"' style='cursor:pointer;' align='absmiddle' onclick='fmdexf_showAceEditorJs(\""+
				rId+"\", "+cId+", \""+fmd_i18n_javascript+"\", \"javascript\", "+this.grid.isEditor+")' " +
				"onmouseover='changeicosize(this,true)' onmouseout='changeicosize(this,false)'/><span>"+alt+"</span>",
				val);
		this.cell.firstChild.value = val;
		this.cell.childNodes[1].value = args;
		return true;
	};
	this.getArgs = function() {
		//console.debug("this.cell.childNodes[1].value="+this.cell.childNodes[1].value);
		return this.cell.childNodes[1].value ? JSON.parse(this.cell.childNodes[1].value) : null; // get value
	};
	this.getValue = function() {
		//console.debug("eXcell_ace_javascript getValue value="+this.cell.firstChild.value);
		return this.cell.firstChild.value; // get value
	};
}
eXcell_ace_javascript.prototype = new eXcell; // nest all other methods from base class

//ace_html excell type
function eXcell_ace_html(cell) { //excell name is defined here
	if (cell) { //default pattern, just copy it
		this.cell = cell;
		this.grid = this.cell.parentNode.grid;
		//this.cell.innerHTML = "<input type='hidden'/><img src='"+this.grid.extIconPath+"display.png"+"'/>";
	};
	this.edit = function(){}; //read-only cell doesn't have edit method
    this.isDisabled = function(){ return true; };
	this.setValue = function(val) {
		var rId=this.cell.parentNode.idd;	//rowId
    	var cId=this.cell._cellIndex;	//column index
    	var alt_edit = "<font color='gray'>"+this.grid.i18n.extypes_edit+"</font>";
		var alt_sel = "<font color='gray'>"+this.grid.i18n.extypes_sel+"</font>";
		var alt_view = "<font color='gray'>"+this.grid.i18n.extypes_view+"</font>";
		var alt = this.grid.isEditor ? (val ? alt_edit : alt_sel) : alt_view;
		var imgName = val ? "update.gif" : "new.gif";
		this.setCValue("<input type='hidden'/><img src='"+this.grid.extIconPath+imgName+
				"' style='cursor:pointer;' align='absmiddle' onclick='fmdexf_showAceEditor(\""+
				rId+"\", "+cId+", \""+fmd_i18n_htmlseg+"\", \"html_completions\", "+this.grid.isEditor+")' " +
				"onmouseover='changeicosize(this,true)' onmouseout='changeicosize(this,false)'/>"+alt,
				val);
		this.cell.firstChild.value = val;
	};
	this.getValue = function() {
		return this.cell.firstChild.value; // get value
	};
}
eXcell_ace_html.prototype = new eXcell; // nest all other methods from base class

//validation excell type, using ace javascript editor
function eXcell_ace_validation(cell) { //excell name is defined here
	if (cell) {
		this.cell = cell;
		this.grid = this.cell.parentNode.grid;
	};
	this.edit = function(){}; //read-only cell doesn't have edit method
    this.isDisabled = function(){ return true; };
    this.setConfig = function(conf) {
    	//console.debug("setConfig="+JSON.stringify(conf));
    	this.cell.childNodes[1].value = conf.args ? JSON.stringify(conf.args) : "";
    	this.cell.childNodes[2].value = conf.params ? JSON.stringify(conf.params) : "";
	};
	this.setArgs = function(a) {
    	//console.debug("setArgs="+JSON.stringify(a));
    	this.cell.childNodes[1].value = a ? JSON.stringify(a) : "";
	};
	this.setParams = function(p) {
    	//console.debug("setParams="+JSON.stringify(p));
    	this.cell.childNodes[2].value = p ? JSON.stringify(p) : "";
	};
	this.setValue = function(val) {
		typeof(val)=='object' && (val = JSON.stringify(val));
		//console.debug("eXcell_ace_validation setValue value="+val);
		var rId=this.cell.parentNode.idd;	//rowId
    	var cId=this.cell._cellIndex;	//column index
    	var alt_edit = "<font color='gray'>"+this.grid.i18n.extypes_edit+"</font>";
		var alt_sel = "<font color='gray'>"+this.grid.i18n.extypes_sel+"</font>";
		var alt_view = "<font color='gray'>"+this.grid.i18n.extypes_view+"</font>";
    	this.cell.firstChild.value = val;
		var imgName = (val && val!='{}') ? "update.gif" : "new.gif";
		var alt = this.grid.isEditor ? (val ? alt_edit : alt_sel) : alt_view;
		var args = (this.cell.childNodes && this.cell.childNodes.length>1 && this.cell.childNodes[1] && this.cell.childNodes[1].value)
				? this.cell.childNodes[1].value : "";
		var params = (this.cell.childNodes && this.cell.childNodes.length>2 && this.cell.childNodes[2] && this.cell.childNodes[2].value)
				? this.cell.childNodes[2].value : "";
		this.setCValue("<input type='hidden'/><input type='hidden'/><input type='hidden'/><img src='"+this.grid.extIconPath+imgName+
				"' style='cursor:pointer;' align='absmiddle' onclick='fmdexf_showAceValidationJs(\""+
				rId+"\", "+cId+", \""+fmd_i18n_validation+"\", \"javascript\", "+this.grid.isEditor+")' " +
				"onmouseover='changeicosize(this,true)' onmouseout='changeicosize(this,false)'/><span>"+alt+"</span>",
				val);
		this.cell.firstChild.value = val;
		this.cell.childNodes[1].value = args;
		this.cell.childNodes[2].value = params;
		return true;
	};
	this.getArgs = function() {
		//console.debug("getArgs this.cell.childNodes[1].value="+this.cell.childNodes[1].value);
		return this.cell.childNodes[1].value ? JSON.parse(this.cell.childNodes[1].value) : null; // get value
	};
	this.getParams = function() {
		//console.debug("getParams this.cell.childNodes[2].value="+this.cell.childNodes[2].value);
		return this.cell.childNodes[2].value ? JSON.parse(this.cell.childNodes[2].value) : null; // get value
	};
	this.getValue = function() {
		//console.debug("eXcell_ace_validation getValue value="+this.cell.firstChild.value);
		return this.cell.firstChild.value; // get value
	};
}
eXcell_ace_validation.prototype = new eXcell; // nest all other methods from base class

//data binding excell type
function eXcell_databinding(a) {
	if (a)
		this.cell = a, this.grid = this.cell.parentNode.grid;
	this.edit = function () {
		this.cell.atag = !this.grid.multiLine && (_isKHTML || _isMacOS || _isFF) ? "INPUT" : "TEXTAREA";
		this.val = this.getValue();
		this.obj = document.createElement(this.cell.atag);
		this.obj.setAttribute("autocomplete", "off");
		this.obj.style.height = this.cell.offsetHeight - (_isIE ? 4 : 4) + "px";
		this.obj.className = "dhx_combo_edit";
		this.obj.wrap = "soft";
		this.obj.style.textAlign = this.cell.style.textAlign;
		this.obj.onclick = function (a) {
			(a || event).cancelBubble =
				!0;
		};
		this.obj.onmousedown = function (a) {
			(a || event).cancelBubble = !0;
		};
		this.obj.value = this.val;
		this.cell.innerHTML = "";
		this.cell.appendChild(this.obj);
		this.obj.onselectstart = function (a) {
			a || (a = event);
			return a.cancelBubble = !0;
		};
		_isIE && this.obj.focus();
		this.obj.focus();
	};
	this.getValue = function () {
		return this.cell.firstChild && this.cell.atag && this.cell.firstChild.tagName == this.cell.atag ? this.cell.firstChild.value : this.cell._clearCell ? "" : this.cell.innerHTML.toString()._dhx_trim();
	};
	this.detach = function () {
		this.setValue(this.obj.value);
		return this.val != this.getValue();
	};
}
//data binding excell type
eXcell_databinding.prototype = new eXcell;

//process binding excell type
function eXcell_processbinding(a) {
	if (a)
		this.cell = a, this.grid = this.cell.parentNode.grid;
	this.edit = function () {
		this.cell.atag = !this.grid.multiLine && (_isKHTML || _isMacOS || _isFF) ? "INPUT" : "TEXTAREA";
		this.val = this.getValue();
		this.obj = document.createElement(this.cell.atag);
		this.obj.setAttribute("autocomplete", "off");
		this.obj.style.height = this.cell.offsetHeight - (_isIE ? 4 : 4) + "px";
		this.obj.className = "dhx_combo_edit";
		this.obj.wrap = "soft";
		this.obj.style.textAlign = this.cell.style.textAlign;
		this.obj.onclick = function (a) {
			(a || event).cancelBubble =
				!0;
		};
		this.obj.onmousedown = function (a) {
			(a || event).cancelBubble = !0;
		};
		this.obj.value = this.val;
		this.cell.innerHTML = "";
		this.cell.appendChild(this.obj);
		this.obj.onselectstart = function (a) {
			a || (a = event);
			return a.cancelBubble = !0;
		};
		_isIE && this.obj.focus();
		this.obj.focus();
	};
	this.getValue = function () {
		return this.cell.firstChild && this.cell.atag && this.cell.firstChild.tagName == this.cell.atag ? this.cell.firstChild.value : this.cell._clearCell ? "" : this.cell.innerHTML.toString()._dhx_trim();
	};
	this.detach = function () {
		this.setValue(this.obj.value);
		return this.val != this.getValue();
	};
}
//process binding excell type
eXcell_processbinding.prototype = new eXcell;

//btnex excell type
function eXcell_btnex(cell) { //excell name is defined here
	if (cell) {
		this.cell = cell;
		this.cell.parentObj = this;
		this.grid = this.cell.parentNode.grid;
	};
	this.edit = function(){}; //read-only cell doesn't have edit method
    this.isDisabled = function(){ return true; };
    this.setConfig = function(config) {
    	//console.debug("eXcell_btnex setConfig");
    	var rId=this.cell.parentNode.idd;	//rowId
    	var cId=this.cell._cellIndex;	//column index
    	this.cell.btnex_onclick = function(){
    		config.onclick(rId, cId, this.parentObj.grid);//this==cell
    	};
    	if (config.onclick1) {
    		this.cell.btnex_onclick1 = function(){config.onclick1(rId, cId, this.parentObj.grid);};//this==cell
    		this.cell.imgName1 = config.imgName1;
    	}
    	if (config.ishidebtn) {
    		this.cell.ishidebtn=function(){return config.ishidebtn(rId, cId)};
    	}
    	if (config.ishidebtn1) {
    		this.cell.ishidebtn1=function(){return config.ishidebtn1(rId, cId)};
    	}
    	this.cell.displayValue = config.displayValue;
	};
	this.isEmpty = function(obj) {
		if (!obj) return true;
		for (var i in obj) {
			return false;
		}
		return true;
	};
	this.setValue = function(val, triggerCellEdit) {
		if (!this.cell.btnex_onclick) {
			return false;
		}
		var oldval = this.getValue();
		var rId=this.cell.parentNode.idd;	//rowId
    	var cId=this.cell._cellIndex;	//column index
		var imgName = this.isEmpty(val) ? "new.gif" : "update.gif";
		var alt = "";
		var rval = "";
		var alt_edit = "<font color='gray'>"+this.grid.i18n.extypes_edit+"</font>";
		var alt_sel = "<font color='gray'>"+this.grid.i18n.extypes_sel+"</font>";
		var alt_view = "<font color='gray'>"+this.grid.i18n.extypes_view+"</font>";
		//console.debug("eXcell_btnex setValue id="+rId+" value="+val);
		if ('object'==typeof(val)) {
			//console.debug("eXcell_btnex setValue id="+rId+" value is object");
			//console.debug("eXcell_btnex this.cell.displayValue is "+this.cell.displayValue);
			if (val==null || this.isEmpty(val)) {
				alt = this.grid.isEditor ? alt_sel : alt_view;
			} else {
				var dv1 = this.cell.displayValue || "displayValue";
				alt = val[dv1] ? val[dv1] : ( this.grid.isEditor ? alt_edit : alt_view);
			}
			rval = JSON.stringify(val);
			//console.debug("eXcell_btnex setValue id="+rId+" value after="+rval);
			this.cell.valueType = 'object';
		} else {
			//console.debug("eXcell_btnex setValue id="+rId+" value is simple");
			if(this.cell.displayValue) {
				alt = this.grid.isEditor ? (val ? alt_edit : alt_sel) : alt_view;
			}
			this.cell.valueType = 'simple';
			rval = val;
		}
		
		var btnimg=btnimg1="";
		if (!this.cell.ishidebtn || !this.cell.ishidebtn()) {
			btnimg = "<img src='"+this.grid.extIconPath+imgName+
				"' style='cursor:pointer;' align='absmiddle' onclick='fmdexf_btnexClick(event,this,\""+rId+"\", "+cId+", 0)' " +
				"onmouseover='changeicosize(this,true)' onmouseout='changeicosize(this,false)'/>";
		}
		if (this.cell.btnex_onclick1 && !this.isEmpty(val) && (!this.cell.ishidebtn1 || !this.cell.ishidebtn1())) {
			btnimg1 = "&nbsp;<img src='"+this.grid.extIconPath+this.cell.imgName1+
				"' style='cursor:pointer;' align='absmiddle' onclick='fmdexf_btnexClick(event,this,\""+rId+"\", "+cId+", 1)' " +
				"onmouseover='changeicosize(this,true)' onmouseout='changeicosize(this,false)'/>";
		}
		this.setCValue("<input type='hidden'/>"+btnimg + btnimg1 +"&nbsp;<span>"+alt+"</span>",
				rval);
		
		this.cell.firstChild.value = rval;
		//console.debug("eXcell_btnex setValue id="+rId+" value after set="+this.cell.firstChild.value);
		triggerCellEdit && this.grid.callEvent("onEditCell", [2, rId, cId, val, oldval]);
		return true;
	};
	this.getValue = function() {
		if (!this.cell.firstChild) return null;
		var val = this.cell.firstChild.value;
		//var rId=this.cell.parentNode.idd;	//rowId
		//console.debug("eXcell_btnex getValue id="+rId+" value before="+val);
		if(this.cell.valueType=='object') {
			val = (val==null || val=='') ? null : JSON.parse(val);
		}
		//console.debug("eXcell_btnex getValue id="+rId+" value after="+val);
		return val; // get value
	};
}
eXcell_btnex.prototype = new eXcell; // nest all other methods from base class

//this excell type is used when coro is readonly
function eXcell_rocoro(cell){
    if (cell){
        this.cell = cell;
        this.grid = this.cell.parentNode.grid;
    }
    this.setOptions=function(options) {
    	this.cell.options = options;
    };
    this.setValue=function(val){
    	var vd = val;
    	if (this.cell.options && this.cell.options.length>0) {	//combo bind by cell
    		for (var i=0; i<this.cell.options.length; i++) {
    			if (this.cell.options[i][0]==val) {
    				vd =  this.cell.options[i][1];
    				break;
    			}
    		}
    	} else {//get combo bind by column
    		var combo1 = this.grid.getCombo(this.cell._cellIndex);
    		if (combo1 && combo1.keys && combo1.keys.length>0) {
    			for (var i=0; i<combo1.keys.length; i++) {
        			if (combo1.keys[i]==val) {
        				vd =  combo1.values[i];
        				break;
        			}
        		}
    		}
    	}
        this.setCValue("<input type='hidden' value='"+val+"'><span>"+vd+"</span>",val);  
    };
    this.getValue=function(){
    	return this.cell.firstChild ? this.cell.firstChild.value : null;
    };
}
eXcell_rocoro.prototype = new eXcell;
/*function eXcell_rocoro(cell){
	this.base=eXcell_co;
	this.base(cell)
	this.editable=false;
	this.edit = function(){return false;}
	this.detach = function(){return false;}
}
eXcell_rocoro.prototype=new eXcell_co;*/

//ro with overflow-hidden when text is too long
function eXcell_robr(cell){
	if (cell){
		this.cell=cell;
		this.grid=this.cell.parentNode.grid;
	}
	this.edit = function(){}; //read-only cell doesn't have edit method
    this.isDisabled = function(){ return true; }; // the cell is read-only, that's why it is always in the disabled state
    this.setValue=function(val) {
    	if (undefined!=val) {
    		this.setCValue("<span style='white-space:nowrap;overflow:hidden;'>"+val+"</span>",val);
    	} else {
    		this.setCValue("<span style='display:none'></span>",val);
    	}
    };
    this.getValue=function(){
    	//console.log(this.cell.childNodes[0].innerHTML);
    	return this.cell.childNodes[0].innerHTML; // get value
    };
}
eXcell_robr.prototype=new eXcell;

//new eXcell type - colist, is a checkbox list represents key-value pairs data
function eXcell_jquispinner(cell){
	if (cell){
		this.cell=cell;
		this.grid=this.cell.parentNode.grid;
	}
	this.edit=function(){
		this.cell.atag=((!this.grid.multiLine)&&(_isKHTML||_isMacOS||_isFF)) ? "INPUT" : "TEXTAREA";
		this.val=this.getValue();
		this.obj=document.createElement(this.cell.atag);
		this.obj.style.height=(this.cell.offsetHeight-(_isIE ? 4 : 4))+"px";
		this.obj.className="dhx_combo_edit";
		this.obj.wrap="soft";
		this.obj.style.textAlign=this.cell.style.textAlign;
		/*this.obj.onclick=function(e){
			(e||event).cancelBubble=true
		}
		this.obj.onmousedown=function(e){
			(e||event).cancelBubble=true
		}*/
		this.obj.value=this.val
		this.cell.innerHTML="";
		this.cell.appendChild(this.obj);

		/*this.obj.onselectstart=function(e){
			if (!e)
				e=event;
			e.cancelBubble=true;
			return true;
		};*/
		if (_isIE){
			this.obj.focus();
			this.obj.blur();
		}
		//this.obj.focus();
		$(this.obj).spinner(this.cell._conf);
	}
	this.getValue=function(){
		if ((this.cell.firstChild)&&((this.cell.atag)&&(this.cell.firstChild.tagName == this.cell.atag)))
			return this.cell.firstChild.value;

		if (this.cell._clearCell)
			return "";

		return this.cell.innerHTML.toString()._dhx_trim();
	}
	this.setValue=function(val){
		if (!val||val.toString()._dhx_trim() == ""){
			val=" ";
			this.cell._clearCell=true;
		} else
			this.cell._clearCell=false;
		this.setCTxtValue(val);
	}
	this.detach=function(){
		this.setValue(this.obj.value);
		return this.val != this.getValue();
	}
	//init options before using
	this.setConfig = function(conf){
		this.cell._conf=conf;
	};
}
eXcell_jquispinner.prototype = new eXcell;//new eXcell type

function eXcell_roch(cell){
	if (cell){
		this.cell=cell;
		this.grid=this.cell.parentNode.grid;
	}

	this.disabledF=function(fl){
		if ((fl == true)||(fl == 1))
			this.cell.innerHTML=this.cell.innerHTML.replace("item_chk0.", "item_chk0_dis.").replace("item_chk1.",
				"item_chk1_dis.");
		else
			this.cell.innerHTML=this.cell.innerHTML.replace("item_chk0_dis.", "item_chk0.").replace("item_chk1_dis.",
				"item_chk1.");
	}

	this.changeState=function(fromClick){
		this.editor=null;
	}
	this.getValue=function(){
		return this.cell.chstate ? this.cell.chstate.toString() : "0";
	}
	this.setValue=function(fl){
		if ((fl == true)||(fl == 1)||fl=='1')
			this.cell.innerHTML="是";
		else
			this.cell.innerHTML="否";
	}

	this.isCheckbox=function(){
		return true;
	}
	this.isChecked=function(){
		if (this.getValue() == "1")
			return true;
		else
			return false;
	}

	this.setChecked=function(fl){
		this.setValue(fl.toString())
	}
	this.detach=function(){
		return this.val != this.getValue();
	}
	this.edit=null;
}
eXcell_roch.prototype=new eXcell;
